package com.estrend.redbird

import android.app.Application
import android.content.Context
import com.king.frame.mvvmframe.base.BaseApplication
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.FormatStrategy
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber



@HiltAndroidApp
class RedBirdApplication:BaseApplication() {


    override fun onCreate() {
        super.onCreate()
        mContext = this
        initLogger()

    }

    companion object{
     lateinit var mContext: Context
    }

    /**
     * 初始化[Logger]
     */
    private fun initLogger() {
        // 初始化日志打印
        val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder()
            .methodOffset(5)
            .tag(Constants.TAG)
            .build()

        Logger.addLogAdapter(AndroidLogAdapter(formatStrategy))
        Timber.plant(object : Timber.DebugTree() {
            override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
                Logger.log(priority, tag, message, t)
            }
        })
    }
}